var t = getApp();

Page({
    data: {
        title: "搜索",
        inputs: "",
        amout: !1,
        loading: !1,
        goods: [],
        order_by: "",
        order_field: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        classifyBol: !0,
        show: !1
    },
    onLoad: function(t) {
        this.search();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.loading ? console.log("没有更多数据") : this.getMoreData();
    },
    onShareAppMessage: function() {},
    search: function() {
        this.setData({
            goods: []
        }), this.getData();
    },
    getData: function() {
        var a = this, o = t.getNetAddresss("goods.goods.search-goods");
        o += "&search[keyword]=" + this.data.inputs, o += "&page=1", o += "&order_field=" + this.data.order_field, 
        o += "&order_by=" + this.data.order_by, t._getNetWork({
            showToastIn: !1,
            url: o,
            success: function(t) {
                var o = t.data;
                if (1 == o.result) {
                    a.setData({
                        isLoadMore: !0,
                        total_page: o.data.last_page
                    }), a.data.total_page || a.setData({
                        total_page: 0
                    }), a.setData({
                        goods: o.data.data
                    });
                    try {
                        a.setData({
                            goods_template: o.data.goods_template,
                            goods_style_set: o.data.goods_style_set
                        }), "02" == a.data.goods_template.names || "03" == a.data.goods_template.names ? a.setData({
                            show: !0,
                            classifyBol: !1
                        }) : a.setData({
                            show: !1,
                            classifyBol: !0
                        });
                    } catch (t) {
                        console.log(e);
                    }
                }
            },
            fail: function(t) {}
        });
    },
    sortOut: function(t) {
        var a = t.detail.order_by, o = t.detail.order_field;
        0 != this.data.goods.length && (this.setData({
            goods: [],
            order_field: o,
            order_by: a
        }), this.getData());
    },
    classifyBolbtn: function() {
        this.data.show ? this.setData({
            show: !1,
            classifyBol: !0
        }) : this.setData({
            show: !0,
            classifyBol: !1
        });
    },
    getMoreData: function() {
        var a = this;
        a.isLoadMore = !1;
        var o = t.getNetAddresss("goods.goods.search-goods");
        o += "&search[keyword]=" + this.data.inputs, o += "&order_field=" + this.data.order_field, 
        o += "&order_by=" + this.data.order_by, this.data.page >= this.data.total_page ? a.setData({
            loading: !0
        }) : (a.setData({
            page: this.data.page + 1
        }), o += "&page=" + this.data.page, t._getNetWork({
            showToastIn: !1,
            url: o,
            success: function(t) {
                var o = t.data;
                if (1 == o.result) {
                    var s = o.data.data;
                    a.setData({
                        goods: a.data.goods.concat(s)
                    });
                } else a.setData({
                    page: a.data.page - 1,
                    loading: !0,
                    isLoadMore: !1
                });
            },
            fail: function(t) {}
        }));
    },
    inpbtn: function(t) {
        var a = t.detail.value;
        this.setData({
            inputs: a
        });
    },
    inpbtnclear: function() {
        this.setData({
            inputs: ""
        });
    }
});